Ext.define('byb.view.system.AdmOrgTreeViewWindow', {
	extend : "Ext.window.Window",
	alias : 'widget.admOrgTreeViewWindow',
	requires:['byb.view.system.AdmOrgTreeView'],
	autoShow : true,
	title : '选择所属组织',
	autoScroll : true,
	width:430,
	height: 495,
    modal: true,
    bodyStyle:'background:white',
	initComponent : function() {
		this.callParent(arguments);
	},
	items : [{
		xtype:'admOrgTreeView'
		,width: 400
		,height: 410 
	    ,dockedItems: [{
	        xtype: 'toolbar',
	        items: [{
	            text: '全部展开',
	            handler: function(){
	           	 Ext.ComponentQuery.query('admOrgTreeView')[0].expandAll();
	            }
	        }, {
                text: '全部收起',
	            handler: function(){
	           	 Ext.ComponentQuery.query('admOrgTreeView')[0].collapseAll();
	            }
	        }]
	    }]
		,listeners:{
			itemclick:function( ctx, record, item, index, e, eOpts ){
	    		var names = [];
	    		var node = record;
	    	    names.push(node.data.text);
	    	    while(node.parentNode && node.parentNode.data.text !== 'Root'){
	    	    	node = node.parentNode;
	    	    	names.push(node.data.text);
	    	    }
	    	    var orgDesc = names.reverse().join('->');
	    		var id = record.data.id;
	    		
	    		Ext.ComponentQuery.query('admUserForm form textfield[name=orgDesc]')[0].setValue(orgDesc);
	    		Ext.ComponentQuery.query('admUserForm form textfield[name=orgId]')[0].setValue(id);
	    	}
		}
	}]
	,buttons: [{
	        text: '关闭',
	        handler:function(){
	        	Ext.ComponentQuery.query('admOrgTreeViewWindow')[0].close();
        }
    }]
});